<?php

if (function_exists('register_sidebar')) register_sidebar(array('before_widget' => '<li id="categories">','after_widget' => '</li>')); 

class Headerimg
	{
		
		var $style;
		var $version;
		
			function get_style(){
				$this->style = get_option('dipdolt_style');
			}
	}
	
$dipdolt = new Headerimg();
$dipdolt->get_style();
$dipdolt->version = "0.13";

if (!get_option('dipdolt_version') || get_option('dipdolt_version') < $dipdolt->version){
	// Headerimg isn't installed, so we'll need to add options
	if (!get_option('dipdolt_version') )
		add_option('dipdolt_version', $dipdolt->version, 'Headerimg Version installed');
	else
		update_option('dipdolt_version', $dipdolt->version);
		
	if (!get_option('dipdolt_style') )
		add_option('dipdolt_style', '', 'Location of custom style sheet');
}

if ($_POST['custom_styles']){
	update_option('dipdolt_style', $_POST['custom_styles']);
	wp_cache_flush();
	if ($_POST['custom_styles'] == 'none') $colored = "Blue"; 
	else
	$colored = substr($_POST['custom_styles'], 0, -4);
	$message  = "Color Styles change to <strong>". $colored."</strong>" ;
	$message  = strtoupper($message);
} else if( 'reset' == $_POST['action']) {
	delete_option( 'dipdolt_style' );
	$message  = 'Styles changed to defaults!';
	}

add_action ('admin_menu', 'Headerimg_menu');

function Headerimg_menu() {
	add_submenu_page('themes.php', 'Skin Options', 'Skin Options', 5, 'functions.php', 'menu');
}

function menu() {
global $dipdolt, $message;
?>
<? if($message) : ?>
<div id="message" class="updated fade"><p><?=$message?></p></div>
<? endif; ?>

<div class="wrap" style="position:relative;">
<h2><?php _e('Current Skin'); ?></h2>
<div id="currenttheme">
<?php
if ($dipdolt->style == "white.css") echo "<img src='/wp-content/themes/dipdolts/white.png'>";
if ($dipdolt->style == "black.css") echo "<img src='/wp-content/themes/dipdolts/black.png'>";
if ($dipdolt->style == "green.css") echo "<img src='/wp-content/themes/dipdolts/green.png'>";
if ($dipdolt->style == "") echo "<img src='/wp-content/themes/dipdolts/green.png'>";
if ($dipdolt->style == "red.css") echo "<img src='/wp-content/themes/dipdolts/red.png'>";
if ($dipdolt->style == "blue.css") echo "<img src='/wp-content/themes/dipdolts/blue.png'>";
?>
</div>


<h2><?php _e('Available Skin Option'); ?></h2>

<p><form name="dofollow" action="" method="post">
  <input type="hidden" name="page_options" value="'dofollow_timeout'" />
<label for="dipdolt_0"><img src="/wp-content/themes/dipdolts/white.png" width="200px"><br /><input name="custom_styles" type="radio" id="dipdolt_0" value="white.css" <?php if ($dipdolt->style == "white.css") echo "checked='checked'"; ?> /> White</label><br /><br />
<label for="dipdolt_1"><img src="/wp-content/themes/dipdolts/black.png" width="200px"><br /><input name="custom_styles" type="radio" id="dipdolt_1" value="black.css" <?php if ($dipdolt->style == "black.css") echo "checked='checked'"; ?> /> Black</label><br /><br />
<label for="dipdolt_2"><img src="/wp-content/themes/dipdolts/blue.png" width="200px"><br /><input name="custom_styles" type="radio" id="dipdolt_2" value="blue.css" <?php if ($dipdolt->style == "blue.css") echo "checked='checked'"; ?> /> Blue</label><br /><br />
<label for="dipdolt_3"><img src="/wp-content/themes/dipdolts/green.png" width="200px"><br /><input name="custom_styles" type="radio" id="dipdolt_3" value="green.css" <?php if ($dipdolt->style == "green.css") echo "checked='checked'"; ?> /> Green</label><br /><br />
<label for="dipdolt_4"><img src="/wp-content/themes/dipdolts/red.png" width="200px"><br /><input name="custom_styles" type="radio" id="dipdolt_4" value="red.css" <?php if ($dipdolt->style == "red.css") echo "checked='checked'"; ?> /> Red</label><br />
</p>
<p class="submit left"><input type="submit" name="Submit" value="Apply Skin Style &raquo;" /></p></form>
<form name="dofollow" method="post">
<p class="submit left"><input name="reset" type="submit" value="Default Skin &raquo;" /><input type="hidden" name="action" value="reset" /></p></form>
<div class="clear"></div>
</div>

<?php
}
?>